// store/userStore.js
import {
	defineStore
} from 'pinia';

export const useUserStore = defineStore('user', {
	state: () => ({
		name: '',
		role: '',
		school_name: '',
		student_id: '',
		userId: null,
		username: ''
	}),
	actions: {
		// 初始化用户信息
		initUserInfo(userInfo) {
			this.name = userInfo.name;
			this.role = userInfo.role;
			this.school_name = userInfo.school_name;
			this.student_id = userInfo.student_id;
			this.userId = userInfo.userId;
			this.username = userInfo.username;
		},
		// 清空用户信息
		clearUserInfo() {
			this.name = '';
			this.role = '';
			this.school_name = '';
			this.student_id = '';
			this.userId = null;
			this.username = '';
		}
	}
	// persist: true
});